<?php require_once('Connections/parkwaydb_connection.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "/admin/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}


if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_newslist = 5;
$pageNum_newslist = 0;
if (isset($_GET['pageNum_newslist'])) {
  $pageNum_newslist = $_GET['pageNum_newslist'];
}
$startRow_newslist = $pageNum_newslist * $maxRows_newslist;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_newslist = "SELECT news_id, news_date, news_title FROM tbl_news ORDER BY news_date DESC";
$query_limit_newslist = sprintf("%s LIMIT %d, %d", $query_newslist, $startRow_newslist, $maxRows_newslist);
$newslist = mysql_query($query_limit_newslist, $parkwaydb_connection) or die(mysql_error());
$row_newslist = mysql_fetch_assoc($newslist);

if (isset($_GET['totalRows_newslist'])) {
  $totalRows_newslist = $_GET['totalRows_newslist'];
} else {
  $all_newslist = mysql_query($query_newslist);
  $totalRows_newslist = mysql_num_rows($all_newslist);
}
$totalPages_newslist = ceil($totalRows_newslist/$maxRows_newslist)-1;

$maxRows_rated_articles = 5;
$pageNum_rated_articles = 0;
if (isset($_GET['pageNum_rated_articles'])) {
  $pageNum_rated_articles = $_GET['pageNum_rated_articles'];
}
$startRow_rated_articles = $pageNum_rated_articles * $maxRows_rated_articles;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_rated_articles = "SELECT tbl_rating.id, tbl_rating.total_value, tbl_articles.articles_id, tbl_articles.articles_date, tbl_articles.articles_title FROM tbl_articles, tbl_rating WHERE tbl_rating.id = tbl_articles.articles_id ORDER BY tbl_rating.total_value DESC";
$query_limit_rated_articles = sprintf("%s LIMIT %d, %d", $query_rated_articles, $startRow_rated_articles, $maxRows_rated_articles);
$rated_articles = mysql_query($query_limit_rated_articles, $parkwaydb_connection) or die(mysql_error());
$row_rated_articles = mysql_fetch_assoc($rated_articles);

if (isset($_GET['totalRows_rated_articles'])) {
  $totalRows_rated_articles = $_GET['totalRows_rated_articles'];
} else {
  $all_rated_articles = mysql_query($query_rated_articles);
  $totalRows_rated_articles = mysql_num_rows($all_rated_articles);
}
$totalPages_rated_articles = ceil($totalRows_rated_articles/$maxRows_rated_articles)-1;

$maxRows_linkslist = 5;
$pageNum_linkslist = 0;
if (isset($_GET['pageNum_linkslist'])) {
  $pageNum_linkslist = $_GET['pageNum_linkslist'];
}
$startRow_linkslist = $pageNum_linkslist * $maxRows_linkslist;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_linkslist = "SELECT links_id, links_title, links_url FROM tbl_links ORDER BY links_id DESC";
$query_limit_linkslist = sprintf("%s LIMIT %d, %d", $query_linkslist, $startRow_linkslist, $maxRows_linkslist);
$linkslist = mysql_query($query_limit_linkslist, $parkwaydb_connection) or die(mysql_error());
$row_linkslist = mysql_fetch_assoc($linkslist);

if (isset($_GET['totalRows_linkslist'])) {
  $totalRows_linkslist = $_GET['totalRows_linkslist'];
} else {
  $all_linkslist = mysql_query($query_linkslist);
  $totalRows_linkslist = mysql_num_rows($all_linkslist);
}
$totalPages_linkslist = ceil($totalRows_linkslist/$maxRows_linkslist)-1;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_testimonials = "SELECT testimonials_id, testimonials_date, testimonials_long FROM tbl_testimonials ORDER BY testimonials_date DESC";
$testimonials = mysql_query($query_testimonials, $parkwaydb_connection) or die(mysql_error());
$row_testimonials = mysql_fetch_assoc($testimonials);
$totalRows_testimonials = mysql_num_rows($testimonials);

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_private_gallery = "SELECT * FROM tbl_pictures WHERE pictures_requiredlevel <= 2 ORDER BY pictures_date DESC";
$private_gallery = mysql_query($query_private_gallery, $parkwaydb_connection) or die(mysql_error());
$row_private_gallery = mysql_fetch_assoc($private_gallery);
$totalRows_private_gallery = mysql_num_rows($private_gallery);

$colname_loggedin_user = "-1";
if (isset($_SESSION['ParentID'])) {
  $colname_loggedin_user = $_SESSION['ParentID'];
}
mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_loggedin_user = sprintf("SELECT * FROM tbl_user WHERE user_parent_id = %s", GetSQLValueString($colname_loggedin_user, "text"));
$loggedin_user = mysql_query($query_loggedin_user, $parkwaydb_connection) or die(mysql_error());
$row_loggedin_user = mysql_fetch_assoc($loggedin_user);
$totalRows_loggedin_user = mysql_num_rows($loggedin_user);
?>
<?php
// Only get classes that have actual pictures associated with them, this stops "empty" galleries from being created
mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_classes = "SELECT tbl_class.class_id, tbl_class.class_name, tbl_class.class_year FROM tbl_class RIGHT JOIN tbl_pictures ON tbl_class.class_id = tbl_pictures.pictures_class_id WHERE tbl_pictures.pictures_requiredlevel <= 2 GROUP BY class_name ORDER BY class_year DESC";
$classes = mysql_query($query_classes, $parkwaydb_connection) or die(mysql_error());
$row_classes = mysql_fetch_assoc($classes);
$totalRows_classes = mysql_num_rows($classes);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Arthropod  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20100422

-->
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/site_template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>The Parkway Child Care Centre and Beaumont Hills Longday Pre-school</title>
<link rel="stylesheet" href="smoothgallery/css/jd.gallery.css" type="text/css" media="screen" charset="utf-8" />

<!-- InstanceEndEditable -->

<!-- CSS FILES -->
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/datepicker.css" rel="stylesheet" type="text/css" />

<!-- JAVASCRIPT RELATED FILES -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/mosaic.1.0.1.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/eye.js"></script>
<script type="text/javascript" src="js/utils.js"></script>

		
<script type="text/javascript">  
			
			jQuery(function($){
				
				$('.circle').mosaic({
					opacity		:	0.8			//Opacity for overlay (0-1)
				});
				
				$('.fade').mosaic();
				
				$('.bar').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar2').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar3').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top'		//Vertical anchor position
				});
				
				$('.cover').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px'		//Horizontal position on hover
				});
				
				$('.cover2').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top',		//Vertical anchor position
					hover_y		:	'80px'		//Vertical position on hover
				});
				
				$('.cover3').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px',	//Horizontal position on hover
					hover_y		:	'300px'		//Vertical position on hover
				});
		    
		    });
		    
		</script>
<!-- InstanceBeginEditable name="head" -->
<script src="smoothgallery/scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script>
<script src="smoothgallery/scripts/mootools-1.2-more.js" type="text/javascript"></script>
<script src="smoothgallery/scripts/jd.gallery.js" type="text/javascript"></script>
<script src="smoothgallery/scripts/jd.gallery.set.js" type="text/javascript"></script>
 
<script type="text/javascript">
 function startGallery() {
 	var myGallery = new gallerySet($('myGallerySet'), {
 		timed: false,
		textShowCarousel: "All Pictures",
		textGallerySelector: "Classes",
		textShowGallerySelector: "All Classes",
 		showArrows: true,
 		showCarousel: true,
 		embedLinks: false,
		fadeDuration: 1500,
		defaultTransition: "crossfade"
	 });
	 HistoryManager.start();
 }
 window.addEvent('domready', startGallery);
</script>
<!-- InstanceEndEditable -->
</head>
<body>

<div id="wrapper">

    <div id="header">
        <div id="logo">
            <p><h4><a href="index.php">Home</a> | <a href="aboutus.php">About Us</a> | <a href="contactus.php">Contact Us</a> | <img src="images/administrator.png" width="16" height="16" alt="Admin" /><a href="admin/index.php">Admin</a> &nbsp;<br /></h4></p>
            <p>
            <a href="javascript:decreaseFontSize()" class="nohover"><img src="images/font-sizer-down.gif" alt="Decrease font size" width="25" height="25" border="0" /></a>
            <a href="javascript:increaseFontSize()" class="nohover"><img src="images/font-sizer-up.gif" alt="Increase font size" width="25" height="25" border="0" /></a>
            </p>
        </div>
    </div>

  <div id="spacing"> <br /> </div>  
    
  <div id="menuboxes">
    <div class="mosaic-block bar2">
              <a href="news.php" title="View Latest News" class="mosaic-overlay">
              <div class="details">
                <h4>News</h4> 
                <p>Check the latest news!</p>
              </div>
              </a>
            <div class="mosaic-backdrop"><img src="images/1.jpg" width="190" height="200" alt="News"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="gallery.php" title="View the Gallery" class="mosaic-overlay">
              <div class="details">
                <h4>Gallery</h4>
                <p>View pictures</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="images/2.jpg" width="190" height="200" alt="Gallery"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="linksarticles.php" title="View Articles and Links" class="mosaic-overlay">
              <div class="details">
                <h4>Articles and Links</h4>
                <p>Important articles and links</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="images/3.jpg" width="190" height="200" alt="Articles and Links"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="staff.php" title="View Staff Information" class="mosaic-overlay">
              <div class="details">
                <h4>Staff</h4> 
                <p>Details on our Staff</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="images/4.jpg" width="190" height="200" alt="Staff Information"/></div>
        </div>
      </div>

	
  <div id="spacing"> <br /> </div>  
    
  <div id="page">
		<div id="page-bgtop">
				<div id="content"><!-- InstanceBeginEditable name="main_region" -->
         <h1>Private Gallery </h1>
	<?php if ($totalRows_classes > 0) { // Show if recordset not empty ?>
      <div id="myGallerySet" class="nohover"> 
        <?php do { // Loop through all the classes ?>
          <div id="<?php echo $row_classes['class_name'].'_'.$row_classes['class_year']; ?>" class="galleryElement">
              <h2><?php echo $row_classes['class_name']; ?> <?php echo $row_classes['class_year']; ?></h2>
        
                <?php
                // Get pictures that are only linked to this particular Class ID - this is basically a "gallery"
                mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
                $query_private_gallery = "SELECT * FROM tbl_pictures WHERE pictures_requiredlevel <= 2 AND pictures_class_id = ".$row_classes['class_id']." ORDER BY pictures_date DESC";
                $private_gallery = mysql_query($query_private_gallery, $parkwaydb_connection) or die(mysql_error());
                $row_private_gallery = mysql_fetch_assoc($private_gallery);
                $totalRows_private_gallery = mysql_num_rows($private_gallery);
                ?>
        
                  <?php do { // Loop thru images based on linked up classes ID ?>
                    <div class="imageElement">
                      <h2><?php echo $row_private_gallery['pictures_caption']; ?></h2>
                      <p><?php echo $row_private_gallery['pictures_description']; ?></p>
                      <a href="gallery/<?php echo $row_private_gallery['pictures_filename']; ?>" title="<?php echo $row_private_gallery['pictures_caption']; ?>" class="open"></a>
                      <img src="gallery/<?php echo $row_private_gallery['pictures_filename']; ?>" class="full" /> 
                      <img src="gallery/<?php echo $row_private_gallery['pictures_thumbnail']; ?>" class="thumbnail" /> 
                    </div>
                  <?php } while ($row_private_gallery = mysql_fetch_assoc($private_gallery)); // END PIC LOOP ?>
          </div>
        <?php } while ($row_classes = mysql_fetch_assoc($classes)); // END CLASS LOOP ?>
      </div>             
	<?php } // Show if recordset not empty 
	      else {
    		echo "<p>There are currently no private images available for viewing!</p>";
    		echo "<p>Please wait for the website administrators to add images to the gallery</p>"; 
 		  } // end else block 
	?>         
         
 



        <!-- InstanceEndEditable --></div>
			<!-- end #content -->
            <div id="sidebar"><!-- InstanceBeginEditable name="sidebar_region" -->
        					<ul>
						<li>
							<div id="search" >
								<form method="get" action="#">
									<div>
										<input type="text" name="s" id="search-text" value="" /><br />
										<input type="submit" id="search-submit" value="GO" />
									</div>
								</form>
							</div>
							<div style="clear: both;">&nbsp;</div>
						</li>
						<li>
							<h2>Date</h2>
                            <ul>
                            <li><?php print(Date("jS M Y")); ?></li>
                            </ul>
						</li>
						<li>
							<h2>News</h2>
							<ul>
                <?php do { ?>
                              	<li><a href="news.php?news_id=<?php echo $row_newslist['news_id']; ?>"><?php echo $row_newslist['news_title']; ?></a></li>
                              <?php } while ($row_newslist = mysql_fetch_assoc($newslist)); ?>
                            </ul>
						</li>
						<li>
							<h2>Articles</h2>
							<ul>
                <?php do { ?>
                              	<li><a href="articles.php?articles_id=<?php echo $row_rated_articles['articles_id']; ?>"><?php echo $row_rated_articles['articles_title']; ?></a></li>
                              <?php } while ($row_rated_articles = mysql_fetch_assoc($rated_articles)); ?>
                            </ul>
						</li>
						<li>
							<h2>Links</h2>
							<ul>
	<?php do { ?>
							    	<li><a href="<?php echo $row_linkslist['links_url']; ?>"><?php echo $row_linkslist['links_title']; ?></a></li>
								<?php } while ($row_linkslist = mysql_fetch_assoc($linkslist)); ?>
                            </ul>
						</li>
					</ul>

        
<!-- InstanceEndEditable --></div>
                    <!-- end #sidebar -->
			  <div style="clear: both;">&nbsp;</div>
		</div>
	</div>
	<!-- end #page -->
</div>

  <div id="spacing"> <br /> </div>  


<div id="footer">
	<p><a href="index.php">Home</a> | <a href="aboutus.php">About Us</a> | <a href="contactus.php">Contact Us</a> | <a href="news.php">News</a> | <a href="gallery.php">Gallery</a> | <a href="linksarticles.php">Links and Articles</a> | <a href="staff.php">Staff</a> | <a href="admin/index.php">Admin</a></p>
  <p>Copyright &copy; 2011 The Parkway Child Care Centre and Beaumont Hills Longday Pre-school. All rights reserved.<br />
Website Design by Igor Chuprov</p><br />
</div>
<!-- end #footer -->
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($newslist);

mysql_free_result($rated_articles);

mysql_free_result($linkslist);

mysql_free_result($testimonials);

mysql_free_result($private_gallery);

mysql_free_result($loggedin_user);

mysql_free_result($classes);
?>
